
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>研线文库-你的移动考研图书馆！</title>
    <meta name="keywords" content="考研资料,考研真题,专业课真题,复试,调剂,招生信息,研线网, 2022考研。">
    <meta name="description"
        content="研线文库为广大考生提供全面的考研择校、考研备考、考研经验、考研真题、考研复试、考研调剂等资料。致力于为广大学子提供便捷的高质量资料平台，一站式解决你的资料难题，助力考研成功！">
    <link rel="stylesheet" href="/public/images/library/css/wklogin.css">
    <style>
        .login_box #login {border-radius: 0 !important; }
        .connent_wrap2 {display: block; }
    </style>
    <script src="/public/images/library/js/adapt.js"></script>
</head>

<body>
    <div class="login_box1">
        <img class="back" src="/public/images/library/images/leftB.png" alt="">
        <div class="bg">
            <img src="/public/images/library/images/wk_bg.png" alt="">
        </div>
        <div class="login_box">
            <input type="hidden" value="/library" id="returnUrl">

            <div class="title">注册文库账号</div>
            <div class="longin_wrap"></div>

            <div class="connent_wrap2">
                <div class="connent_item">
                    <div class="input_box zj">
                        <input type="hidden" value="Quick" id="quick">
                        <img src="/public/images/library/images/code.png" alt="">
                        <input class="phone" type="text" name="" id="phone" placeholder="手机号">
                    </div>
                    <div class="input_box zj">
                        <img src="/public/images/library/images/code.png" alt="">
                        <input class="phone" type="text" name="" id="yztxm" placeholder="图形码">
                        <img id="txm" src="/login/index/verify" alt="captcha"
                            onclick="this.src='/login/index/verify?'+Math.random();" class="verify_div" />
                    </div>
                    <div class="input_box zj">
                        <img src="/public/images/library/images/code.png" alt="">
                        <input class="phone" type="text" name="" id="phonecodeDiv" placeholder="动态码">
                        <div id="dtm">
                            获取
                        </div>
                    </div>
                    <div class="input_box zj">
                        <img src="/public/images/library/images/sj.png" alt="">
                        <input class="phone" type="password" name="" id="phonePwd" placeholder="密码">
                    </div>
                    <div class="input_box zj input_box1">
                        <input type="submit" id="register" value="登录">
                    </div>
                </div>
            </div>
        </div>
        <div id="v_container"></div>
    </div>
    <script src="/public/images/library/js/jquery.js"></script>
    <script src="/public/images/library/js/md5.js"></script>
    <script src="/public/images/library/js/gVerify.js"></script>
    <script src="/public/images/library/js/layer/mobile/layer.js"></script>
    <script>
        var verifyCode = new GVerify("v_container");
        console.log(verifyCode,'///');
        var myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;

        function phone_code(obj, targetData) {
            var timestamp = new Date().getTime();
            var phone = $("#phone").val();
            var sign = "username=" + phone + "&time" + timestamp;
            var sign5 = hex_md5(sign);
            var captcha = $("#yztxm").val();
            //验证移动电话
            var data = targetData;
            console.log(data, '===');
            if (!(myreg.test(data))) {
                // $("#errorInfo1").html("请输入正确的手机号！");
                // $("#checkPhone1").show();
                layer.open({
                    content: '请输入正确的手机号！',
                    skin: 'msg',
                    time: 2,
                })
                return false;
            }
            console.log(captcha, "--captcha");
            if (captcha == "") {
                // $("#errorInfo1").html("请输入图形验证码!");
                // $("#checkPhone1").show();
                layer.open({
                    content: '请输入图形验证码！',
                    skin: 'msg',
                    time: 2,
                })
                return false;
            }
            //验证登录名称是否重复
            $.ajax({
                url: "/login/index/code",
                type: "post",
                dataType: "json",
                data: {
                    "username": data,
                    "sign": sign5,
                    "time": timestamp,
                    "captcha": captcha,
                    "source": 2
                },
                success: function (data) {
                    // console.log(data,"--cg");
                    if (data.success == 1) {
                        invokeSettime(obj);
                    } else {
                        layer.open({
                            content: data.msg,
                            skin: 'msg',
                            time: 2,
                        })
                    }
                }
            });
        }

        function invokeSettime(obj) {
            var countdown = 60;
            settime(obj);

            function settime(obj) {
                if (countdown == 0) {
                    $(obj).attr("disabled", false);
                    $(obj).html("获取验证码");
                    countdown = 60;
                    return;
                } else {
                    $(obj).attr("disabled", true);
                    $(obj).html("(" + countdown + ") s 获取");
                    countdown--;
                }
                setTimeout(function () {
                    settime(obj)
                }, 1000)
            }
        }


        $("#dtm").click(function () {
            var username = $("#phone").val();
            phone_code(this, username);
        });

        $("#register").click(function () {

            //验证非空
            $.ajax({
                url: "/reg/Index/index",
                type: "POST",
                data: ({
                    username: $("#phone").val(),
                    code: $("#phonecodeDiv").val(),
                    password: $("#phonePwd").val(),
                    source_url_h5: $("#returnUrl").val()
                }),
                dataType: "json",
                beforeSend: function () {
                    var username = $("#phone").val();
                    if (!(myreg.test(username))) {
                        layer.open({
                            content: '请输入手机号!',
                            skin: 'msg',
                            time: 2,
                        })
                        return false;
                    }
                    var captcha = $("#captcha").val();
                    if (captcha == "") {
                        layer.open({
                            content: '请输入图形验证码!',
                            skin: 'msg',
                            time: 2,
                        })
                        return false;
                    }
                    var code = $("#phonecodeDiv").val();
                    if (code == "") {
                        layer.open({
                            content: '请输入6位动态码!',
                            skin: 'msg',
                            time: 2,
                        })
                        return false;
                    }

                },
                success: function (data) {
                    console.log(data)
                    if (data.success == 1) {
                        $("#register").html("注册成功...");
                        setTimeout(function () {
                            location.href = 'https://mk.yanxian.org/activity/library/wklogin?url=' + '/library';
                        }, 1000);
                    } else {
                        layer.open({
                            content: data.msg,
                            skin: 'msg',
                            time: 2,
                        })

                    }
                }
            });
        })

        $('.back').click(() => {
            window.history.back();
        })
    </script>
</body>

</html>